package com.example.chao.myphotosearch.view.fragments;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;

import com.example.chao.myphotosearch.R;
import com.example.chao.myphotosearch.adapters.JoyAdapter;
import com.example.chao.myphotosearch.bean.ImageJoy;
import com.example.chao.myphotosearch.model.DaggerLaunchComponent;
import com.example.chao.myphotosearch.presenter.IPresenter;
import com.example.chao.myphotosearch.presenter.JoyFragmentPresenter;
import com.example.chao.myphotosearch.view.ISwipeView;

import java.util.List;

import javax.inject.Inject;

/**
 * Created by chao on 2016/3/19.
 */
public class JoyFragment extends BaseSwipeFragment<List<ImageJoy>> {

    @Inject
    JoyFragmentPresenter joyFragmentPresenter;

    @Inject
    JoyAdapter joyAdapter;
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        DaggerLaunchComponent.create().inject(this);
    }


    @Override
    public int getLayoutID() {
        return R.layout.fragment_main;
    }

    @Override
    public void initParams() {
//        joyFragmentPresenter.onCreate(this);
        super.initParams();
        mainRV.setLayoutManager(new LinearLayoutManager(getActivity()));
        mainRV.setAdapter(joyAdapter);
    }

    @Override
    public IPresenter<ISwipeView<List<ImageJoy>>> getPresenter() {
        return joyFragmentPresenter;
    }

    @Override
    public void attachView(List<ImageJoy> joys) {
        joyAdapter.setJoys(joys);
    }

}
